﻿//****************************************************************************
// Copyright (c) 2010 All Right Reserved, http://www.sublight.si/
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from
// the use of this software.
//
// The origin of this software must not be misrepresented; you must not claim
// that you wrote the original software. If you use this software in a product,
// an acknowledgment in the product documentation is required.
//
// Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// The source code of the program may be copied and used for educational,
// non-commercial purposes. The source code may be modified if desired,
// to suit the user.
//
// This notice may not be removed or altered from any source distribution.

using System;
using System.IO;
using NConsoler;
using Utility.Video;

namespace SublightCmd
{
    partial class Program
    {
        /// <summary>
        /// SublightCmd help calculatehash
        /// SublightCmd calculatehash "C:\video.avi"
        /// </summary>
        [Action("calculates video hash and writes it to standard output")]
        public static void CalculateHash(
            [Required(Description = "Path to video file")]
            string filePath
            )
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    throw new Exception("File does not exist");
                }
                string hash = Checksum.Compute(filePath);
                Console.WriteLine(hash);
            }
            catch (Exception ex)
            {
                Environment.ExitCode = 1;
                Console.Error.WriteLine(string.Format("Error occured: {0}", ex.Message));
            }
        }
    }
}
